// =================calender 插件===============================================================
function showdate(json, showyear, showmonth ,wropbox) {
//当月数据，当月年份，当月月份，提前天数,删除天数（数组）
    /*日历*/
    // 20170302 字符转换
    var showyear=Number(showyear);
    var showmonth=Number(showmonth);
    var solarMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    var nStr1 = new Array('日', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十');
    //返回公历y年m+1月的天数
    function solarDays(y, m) {
        if (m == 1)
            return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28);
        else
            return (solarMonth[m]);
    }
    //记录公历的日期
    function calElement(sYear, sMonth, sDay, week) {
        this.isToday = false;
        //公历
        this.sYear = sYear;
        this.sMonth = sMonth;
        this.sDay = sDay;
        this.week = week;
    }
    //保存y年m+1月的相关信息
    function calendar(y, m) {
        var sDObj;
        sDObj = new Date(y, m, 1);  //当月第一天的日期
        this.length = solarDays(y, m);    //公历当月天数
        this.firstWeek = sDObj.getDay(); //公历当月1日星期几
        for (var i = 0; i < this.length; i++) {
            this[i] = new calElement(y, parseInt(m)+ 1, i + 1, nStr1[(i + this.firstWeek) % 7]);
            if ((i + this.firstWeek) % 7 == 0) {
                this[i].color = '#ccc';  //周日颜色
            }
        }
        if (y == tY && m == tM) this[tD - 1].isToday = true;    //今日
    };

    var cld;
    function drawCld(SY, SM) {
        var i, sD;
        var icon="icon01"//定义角标匹配的class
        cld = new calendar(SY, SM);
        var recommendday=false;
        for (i = 0; i < 42; i++) {
            var sObj = wropbox.find('#SD' + i);
            var lObj = wropbox.find('#LD' + i);
            sObj.parent().removeClass("active");
            sD = i - cld.firstWeek;
            //计算提前天数
            var Today = new Date();
            function AddDays(date,value) {
                return new Date(Date.parse(date) + (86400000 * (value - 1)));
            };
            var leadtime = AddDays(Today, tqts);
            sObj.parent("td").removeClass("recommendday");
            if (sD > -1 && sD < cld.length) { //日期内
                sObj.text(sD + 1);
                sObj.data("date", SY + "-" + (SM + 1) + "-" + (sD + 1));
                sObj.parent("td").removeClass(icon);
                if (alldaty[parseInt(sD)].flag && new Date(SY, SM, sD + 1) > leadtime) {
                    sObj.parent().addClass("active");
                    sObj.next("span").text(alldaty[parseInt(sD)].count);
                    sObj.parent("td").data("date",SY+"-"+(SM+1)+"-"+(sD + 1));
                    var $delweekday=xxr;//指定星期几休息变量
                    _delweekday=$delweekday.split("|");
                    var is_delweekday=false;
                    for(var n = 0; n < _delweekday.length; n++) {
                        if(new Date(SY, SM, sD+1).getDay()==_delweekday[n]&&_delweekday[n].length>0){//指定星期几休息
                            sObj.parent().removeClass("active");
                            lObj.text("休息");
                            is_delweekday=true;
                        }
                    };


                    // if(!recommendday&&SM==tM&&!is_delweekday){
                    // sObj.parent("td").addClass("recommendday");
                    // recommendday=true;
                    // };

                }
                else {
                    if (new Date(SY, SM, sD+1) >=new Date(tY,tM,tD) && new Date(SY, SM, sD+1)< leadtime ){
                        sObj.parent("td").addClass(icon);//给提前的几天加角标class
                        lObj.text("");
                        sObj.parent("td").data("tipbox","需提前"+tqts+"天预约");
                    }else{
                        lObj.text("");
                    }
                }

                if(alldaty[parseInt(sD)].txt){
                    //加节假日注释和约满判断
                    if(alldaty[parseInt(sD)].dataflag==1){
                        lObj.text(alldaty[parseInt(sD)].txt);//约满
                    }else if(alldaty[parseInt(sD)].dataflag==2){//加节假
                        lObj.text("");sObj.parent("td").addClass(icon);
                        sObj.parent("td").data("tipbox",alldaty[parseInt(sD)].txt);
                    }else{
                        sObj.parent().addClass("active");
                        lObj.text(alldaty[parseInt(sD)].txt);
                        sObj.parent("td").data("date",SY+"-"+(SM+1)+"-"+(sD + 1));
                    };

                };
                sObj.parent("td").removeClass("isToday");
                if (cld[sD].isToday) {sObj.parent("td").addClass("isToday");sObj.next("span").text("今天");
                    sObj.parent().removeClass("active");//设置今天不可点击
                }; //今日颜色
            }
            else { //非日期
                sObj.text("");
                lObj.text("");
                sObj.parent("td").removeClass(icon);
            }
            if(SM==tM){
                sObj.parents("table").eq(0).find("td.active").eq(0).addClass("recommendday");
            }
        }
        var $ptext = wropbox.find(".tablediv tbody tr:last td:first p:first");
        if ($ptext.text()) {
            $ptext.parents("tr").css("display", "table-row");
        } else {
            $ptext.parents("tr").css("display", "none");
        }
    }
    //用自定义变量保存当前系统中的年月日
    var Today = new Date();
    var tY = Today.getFullYear();
    var tM = Today.getMonth();
    var tD = Today.getDate();
    //设置的时间
    var setYear = tY;
    var setMonth = tM;
    //打开页时,在下拉列表中显示当前年月,并调用自定义函数drawCld(),显示公历和农历的相关信息
    var alldaty = [];//保存所以天数数据
    var nowdat = [];
    var xxr;
    var tqts;
    if (json) {
        // json.returnDay.sort(function (a, b) {
        //     var time1 = new Date(a);
        //     var time2 = new Date(b);
        //     return time1 - time2;
        // });

        if(typeof json!=="string"){}else{json=JSON.parse(json);};

        nowdat = json.data;
        xxr=json.xxr;
        tqts=json.tqts;
    }
    function initial(y, m) {
        var datalength = solarDays(y, m);
        var noday = 0;//保存没有日期下一天位置
        var sDObj = new Date(y, m, 1);//当月第一天
        var firstWeek = sDObj.getDay(); //公历当月1日星期几
        alldaty = [];//清空当月数据

        for (var i = 0; i < datalength; i++) {
            var nowday = new Date(y, m, i + 1);//当天时间;
            var nowWeek = nowday.getDay(); //公历当月当日星期几
            var obj = {};
            obj.TJRQ = i;
            var isdelday = true;
            var str=[];
            var m01=m+1;
            var d01=i+1;
            str.push(y,m.toString().length<2&&m!==9?"0"+m01:m01,d01.toString().length<2?"0"+d01:d01);
            var str01=str.join("-");
            var k;
            for(var z=0;z<nowdat.length;z++){
                if (nowdat[z].date==str01) {
                    // var deleteday = (new Date(nowdat[noday].date.replace(/-/g, "/")));
                    k=z;
                    isdelday = false //如果是0，为删除天
                }
            }
            if (!isdelday) {
                //obj.count="不可约";
                obj.count ="";
                obj.txt =nowdat[k].text;
                obj.dataflag=nowdat[k].flag;
                obj.flag = false;
                noday++;
            } else {

                obj.count = "可约";
                obj.flag = true;
            };
            alldaty.push(obj);
        };
        wropbox.find(".controldiv p").html(y + "<span>年</span>" + (m + 1) + "<span>月</span>");
        var prev = {};
        var next = {};
        if (setMonth == 0) {
            prev.year = setYear - 1;
            prev.month = 11;
            next.year = setYear;
            next.month = setMonth + 1;

        } else if (setMonth == 11) {
            prev.year = setYear;
            prev.month = setMonth - 1;
            next.year = setYear + 1;
            next.month = 0;
        } else {
            prev.year = setYear;
            prev.month = setMonth - 1;
            next.year = setYear;
            next.month = setMonth + 1;
        }
        // 20170302 切换改变
        wropbox.find(".controldiv a.left").attr("data-year", prev.year).attr("data-month", prev.month);
        wropbox.find(".controldiv a.right").attr("data-year", next.year).attr("data-month", next.month);
        drawCld(y, m);
    };
    setYear = showyear;
    setMonth = showmonth;
    initial(setYear, setMonth); //初始化日历控件
};
// 渲染日历结构
var showtable = function (elemment) {
    var gNum;
    var trarr = [];
    var trstr = "";
    for (var i = 0; i < 7; i++) {
        trstr = '<tr align="center">';
        for (var j = 0; j < 7; j++) {
            gNum = i * 7 + j;
            trstr += '<td id="GD' + gNum + '"><p id="SD' + gNum + '"></p><span id="LD' + gNum + '"></span></td>';
        }
        trstr += '</tr>';
        trarr.push(trstr);
    }
    elemment.append(trarr.join(""));
    $(elemment).find("tr:odd").addClass("color01");
}


/*加减按钮 在页面里定义*/
// $(".controldiv").on("click", "a.left,a.right", function () {
//     var $this = $(this);
//     var getyear = $this.data("year");
//     var germonth = $this.data("month");

//     $.ajax({
//              url: "calenderjson.json",
//              async:"true",
//              dataType:"json",
//              type:"get",
//              success: function(data){
//              showdate(data, getyear, germonth);
//              $("")

//                },
//                error:function(){
//             alert("flase")
//                }
//     }); 

// });

//一开始先加载渲染日历 在页面里定义
// stratshowdate=function(){
// $.ajax({
//          url: "calenderjson.json",
//          async:"true",
//          dataType:"json",
//          type:"get",
//          success: function(data){
// showdate(data, new Date().getFullYear(), new Date().getMonth());

//            },
//            error:function(){
// alert("flase")
//            }
//   });
// };
// stratshowdate();
// ========================calender插件 end==============================





// ======scroll_fixed=====================================================
// kktj_scroll_fixed({
//     id: ".topbox .fix_element .right01",
//     foot_classname: "foot",
//     foot_distence: $('.section09').css("paddingBottom"),
//     offsettop: ".topbox .fix_element"
// });
kktj_scroll_fixed = function(_parm) {
    // id,foot_classname,foot_distence,offsettop,callback_a,callback_b
    var parm = $.extend({}, _parm);

    var id = parm.id
    foot_classname = parm.foot_classname,
        foot_distence = parm.foot_distence, //if the last element have distance to the footbar,get the diantance
        offsettop = parm.offsettop, //if the element is not static,find other subelement to get the offset
        callback_a = parm.callback_a,
        callback_b = parm.callback_b;

    var c = offsettop;
    $(window).scroll(function() {
        changePosa_(id, _getHeight, tofoot, obj);
    });

    var obj = $(id)[0];
    var _getHeight = c ? $(c).offset().top : $(id).offset().top;
    var uu = function() {
        var a = $("." + foot_classname).offset().top;
        return a;
    }
    var foot_offset_h = typeof(foot_classname) == "undefined" ? $("body").height() : $("." + foot_classname).offset().top; //foot offsettop

    var obj_margintop = Number($(obj).css("marginTop").replace("px", "")) || 0;
    var foot_distence = typeof(foot_distence) == "undefined" ? "0" : foot_distence;
    var tofoot = foot_offset_h - $(obj).outerHeight() - Number(foot_distence.replace("px", "")) || 0;

    function changePosa_(id, height, foot, obj) {
        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
        if (scrollTop < height) {
            obj.style.position = 'relative';
            obj.style.marginTop = '';
            typeof(callback_a) == "undefined" ? "" : eval(callback_a);
        } else {
            typeof(callback_b) == "undefined" ? "" : eval(callback_b);
            scrollTop > foot ? function() {
                    obj.style.position = 'relative';
                    obj.style.marginTop = '0';
                    obj.style.top = (foot - height + obj_margintop) + "px";
                }() :
                function() {
                    obj.style.position = 'fixed';
                    obj.style.top = '0';
                    obj.style.marginTop = '0';
                }();
        }
    }
};
// ==========scroll_fixed=====================================================end


//=========model box begin=============================================================
// model_box({
//     btn: "#index .section06 .left .left_top .p02 li",
//     model_inner_content: "#index_expertVideo01",
//     close_btn: ".close",
//     callback: ""
// });
function model_box(data) {
    var arg = $.extend({}, data);
    var a = arg.btn,
        b = arg.model_inner_content,
        c = arg.close_btn,
        d = arg.callback;
    var btn = $(a);
    var box = $(b);
    var closebtn = $(c);
    $(document).on("click", a, function() {
        $("#model_box").fadeIn(150);
        $("body").addClass("modelopen");
        box.fadeIn(100);
        setTimeout(function() { box.addClass("animate"); }, 50);
        if (d) { eval(d); }; //callback function
    });
    $("#model_box").click(function() {
        $(this).fadeOut(500);
        $(".model_box_content").removeClass("animate").fadeOut(80);
        $("body").removeClass("modelopen");
    })
    var f = c ? closebtn : $('#model_box').find(".close"); //判断有没设置关闭按钮
    f.click(function(event) {
        $('.model_box_content').removeClass("animate").fadeOut(80);
        $('#model_box').fadeOut(500);
        $("body").removeClass("modelopen");
    });
    $('.model_box_content').click(function(event) {
        event.stopPropagation();
    });
}
model_box_tip = function(data) {
    var arg = $.extend({}, data);
    var t = arg.txt,
        s = arg.closetime;
    if (!$("#model_box_tip").length) {
        var html = "<div id='model_box_tip' class='model_box_content fade clearfix' style='width: 332px;display: none; min-height: 94px; background-color: rgb(255, 255, 255); border-radius: 5px; padding-top: 55px; padding-bottom: 15px; margin-left: auto; margin-right: auto; margin-top: 25%;'><div style='text-align: center;'>" + t + "<div><div>"
    };
    $(".model_box_content").hide();
    $("#model_box_tip").find("div").html(t);
    $("#model_box").append(html);
    $("#model_box").fadeIn(150);
    setTimeout(function() { $("#model_box_tip").addClass("animate"); }, 50);
    $("#model_box_tip").fadeIn(100);
    $("body").addClass("modelopen");

    if (typeof s !== "undefined") {
        setTimeout(function() {
            $("#model_box").click();
            $("#model_box_tip").removeClass("animate");
        }, s);

    }
}



//=============== model box end=============================================================




// ===============model_box_tip_independent====================================================
// model_box_tip_independent("11",200000)
model_box_tip_independent = function(data) {
        var arg = $.extend({}, data);
        var t = arg.txt,
            s = arg.closetime;
        if (!$("#model_box_tip01").length) {
            var html = "<div id='model_box_tip_independent'><div id='model_box_tip01' class='fade clearfix' style='width: 332px;display: none; min-height: 94px; background-color: rgb(255, 255, 255); border-radius: 5px; padding-top: 55px; padding-bottom: 15px; margin-left: auto; margin-right: auto; margin-top: 25%;'><div style='text-align: center;'>" + t + "</div></div>"
        };
        $("#model_box_tip_independent").find("div").html(t);
        $("body").append(html);
        $("#model_box_tip_independent").fadeIn(150);
        setTimeout(function() { $("#model_box_tip01").addClass("animate"); }, 50);
        $("#model_box_tip_independent #model_box_tip01").fadeIn(100);
        $("body").addClass("modelopen");

        $("#model_box_tip_independent").click(function() {
            $(this).fadeOut(500);
            $("#model_box_tip_independent").removeClass("animate").fadeOut(80);
            $("body").removeClass("modelopen");
        })
        $('#model_box_tip_independent #model_box_tip').click(function(event) {
            event.stopPropagation();
        });
        if (typeof s !== "undefined") {
            setTimeout(function() {
                $("#model_box_tip_independent").click();
                $("#model_box_tip_independent #model_box_tip01").removeClass("animate");
            }, s);

        }
    }
    // ===================model_box_tip_independent===============end=====================================



//==========tipbox begin===============================================================
tipbox({
    target: ".fix_element .right .right01 .td02",
    dir: "left"
});
// 套餐详情页
// 机构列表页
// data-tipbox  data-tipboxdir  
// target:
// dir:
// tipbox_remain_shown :
function tipbox(data){
    var arg=$.extend({},data);
    var a=$(arg.target);

    $("body").on("mouseenter",arg.target,function(){
        var _this=$(this);
        var bb=function(){
            $(".kktipbox").remove();
            $(".kktipbox_point_box").remove();
            var dir=_this.data("tipboxdir");
            arg.dir?(dir=arg.dir):(dir?"":dir="right");

            var html01="<div class='kktipbox kktipbox_"+dir+"'></div>";
            var html02="<div class='kktipbox_point_box'><div class='kktipbox_point kktipbox_point_"+dir+"'></div></div>";
      
            //if the target elemment is td ，set the appending html out of table
            if(_this.is('td')){
                $("body").after(html01);
                $("body").after(html02);
            }else{
                 $("body").after(html01);
                 $("body").after(html02);
            };

            var top_margin=a.eq(0).css("marginTop")?Number(a.eq(0).css("marginTop").replace("px","")):0;
            var left_margin=a.eq(0).css("marginLeft")?Number(a.eq(0).css("marginLeft").replace("px","")):0;
            var left;
            var top=_this.offset().top;
            var w=_this.innerWidth();
            var h=_this.innerHeight();
            var txt=_this.data("tipbox");
            var _top;
            var kktipbox_top;
            var kktipbox_left;
            var h_icon=$('.kktipbox_point').innerHeight();
            var w_icon=$('.kktipbox_point').innerWidth();
            $(".kktipbox").text("").text(txt);

            if (dir=="right") {_top=top+top_margin-h_icon/2;left=_this.offset().left+w;};
            if (dir=="bottom")  {_top=top+top_margin+h;left=_this.offset().left;};
            if (dir=="top")  {_top=top+top_margin-h;left=_this.offset().left;};
            if (dir=="left")  {_top=top+top_margin-h_icon/2;left=_this.offset().left-w;};
            $(".kktipbox_point_box").css({"height":h,"z-index":1000000,"position":"absolute","width":w,"top":_top,"left":left}).show(0).addClass("active");
            $(".kktipbox").css({"height":"auto","position":"absolute","width":"auto"});
            var box_h=$(".kktipbox").outerHeight();
            var box_w=$(".kktipbox").outerWidth();

            if (dir=="right"){kktipbox_top=top+top_margin-(box_h-h)/2;kktipbox_left=(left+w_icon-1)}
            if (dir=="bottom") {kktipbox_top=top+top_margin+h+h_icon-1;kktipbox_left=left+left_margin-(box_w-w)/2}
            if (dir=="top"){kktipbox_top=top+top_margin-h_icon-box_h+1;kktipbox_left=left+left_margin-(box_w-w)/2}
            if (dir=="left"){kktipbox_top=top+top_margin-(box_h-h)/2;kktipbox_left=(left-box_w+w-w_icon+1)}

            $(".kktipbox").css({"height":$(".kktipbox").height(),"z-index":1000000,"width":$(".kktipbox").width()+1,"top":kktipbox_top,"left":kktipbox_left}).show(0).addClass("active");
        }//兼容谷歌 width加1

        if(arg.tipbox_remain_show){setTimeout(function(){bb()},1);}else{
            bb();
        }//this is need to seting because when the two target is neighbor and have no diatance from each other,the mouseleve whill excute function 1 milisecond later

    });
    var mouseout_hide=true;//key variable of hiding or showing tipbox
    var hidetipbox=function(){
        $(".kktipbox_point_box").hide(0);
        $(".kktipbox").hide(0);
        $(".kktipbox").removeClass("active").remove();
        $(".kktipbox_point_box").removeClass("active").remove();
    }
    $("body").on("mouseleave",arg.target,function(){
        if(arg.tipbox_remain_show){
            setTimeout(function(){
                if(!mouseout_hide){mouseout_hide=true;return};
                hidetipbox();
            },1)
        }else{
            hidetipbox();
        }
    });
    // =============if the mouse moveover ，set the tipbox hide or remain showing
    if(arg.tipbox_remain_show){
        $("body").on("mouseenter",'.kktipbox_point_box',function(event){
            mouseout_hide=false;
        });
        $("body").on("mouseout",'.kktipbox_point_box',function(event){
            setTimeout(function(){
                if(!mouseout_hide){mouseout_hide=true;return}
                hidetipbox();
            },1)
        });
        $("body").on("mouseenter",'.kktipbox',function(event){
            mouseout_hide=false;
        });
        $("body").on("mouseout",'.kktipbox',function(event){
            setTimeout(function(){
                if(!mouseout_hide){return}
                hidetipbox();
            },103)
        });
    }
}
//tipbox end===================================================================









// calender 插件===============================================================
function showdate(json, showyear, showmonth) {

    //当月数据，当月年份，当月月份，提前天数,删除天数（数组）
    /*日历*/
    var solarMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    var nStr1 = new Array('日', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十');
    //返回公历y年m+1月的天数
    function solarDays(y, m) {
        if (m == 1)
            return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28);
        else
            return (solarMonth[m]);
    }
    //记录公历的日期
    function calElement(sYear, sMonth, sDay, week) {
        this.isToday = false;
        //公历
        this.sYear = sYear;
        this.sMonth = sMonth;
        this.sDay = sDay;
        this.week = week;
    }
    //保存y年m+1月的相关信息
    function calendar(y, m) {
        var sDObj;
        sDObj = new Date(y, m, 1); //当月第一天的日期
        this.length = solarDays(y, m); //公历当月天数
        this.firstWeek = sDObj.getDay(); //公历当月1日星期几
        for (var i = 0; i < this.length; i++) {
            this[i] = new calElement(y, parseInt(m) + 1, i + 1, nStr1[(i + this.firstWeek) % 7]);
            if ((i + this.firstWeek) % 7 == 0) {
                this[i].color = '#ccc'; //周日颜色
            }
        }
        if (y == tY && m == tM) this[tD - 1].isToday = true; //今日
    };

    var cld;

    function drawCld(SY, SM) {
        var i, sD;
        var icon = "icon01" //定义角标匹配的class
        cld = new calendar(SY, SM);
        var recommendday = false;
        for (i = 0; i < 42; i++) {
            var sObj = $('#SD' + i);
            var lObj = $('#LD' + i);
            sObj.parent().removeClass("active");
            sD = i - cld.firstWeek;
            //计算提前天数
            var Today = new Date();

            function AddDays(date, value) {
                return new Date(Date.parse(date) + (86400000 * (value - 1)));
            };
            var leadtime = AddDays(Today, tqts);
            sObj.parent("td").removeClass("recommendday");
            if (sD > -1 && sD < cld.length) { //日期内
                sObj.text(sD + 1);
                sObj.data("date", SY + "-" + (SM + 1) + "-" + (sD + 1));
                sObj.parent("td").removeClass(icon);
                if (alldaty[parseInt(sD)].flag && new Date(SY, SM, sD + 1) > leadtime) {
                    sObj.parent().addClass("active");
                    sObj.next("span").text(alldaty[parseInt(sD)].count);
                    sObj.parent("td").data("date", SY + "-" + (SM + 1) + "-" + (sD + 1));
                    var $delweekday = xxr; //指定星期几休息变量
                    _delweekday = $delweekday.split("|");
                    var is_delweekday = false;
                    for (var n = 0; n < _delweekday.length; n++) {
                        if (new Date(SY, SM, sD + 1).getDay() == _delweekday[n] && _delweekday[n].length > 0) { //指定星期几休息
                            sObj.parent().removeClass("active");
                            lObj.text("休息");
                            is_delweekday = true;
                        }
                    };


                    // if(!recommendday&&SM==tM&&!is_delweekday){
                    // sObj.parent("td").addClass("recommendday");
                    // recommendday=true;
                    // };

                } else {
                    if (new Date(SY, SM, sD + 1) >= new Date(tY, tM, tD) && new Date(SY, SM, sD + 1) < leadtime) {
                        sObj.parent("td").addClass(icon); //给提前的几天加角标class
                        lObj.text("");
                        sObj.parent("td").data("tipbox", "需提前" + tqts + "天预约");
                    } else {
                        lObj.text("");
                    }
                }

                if (alldaty[parseInt(sD)].txt) {
                    //加节假日注释和约满判断
                    if (alldaty[parseInt(sD)].dataflag == 1) {
                        lObj.text(alldaty[parseInt(sD)].txt); //约满
                    } else if (alldaty[parseInt(sD)].dataflag == 2) { //加节假
                        lObj.text("");
                        sObj.parent("td").addClass(icon);
                        sObj.parent("td").data("tipbox", alldaty[parseInt(sD)].txt);
                    } else {
                        sObj.parent().addClass("active");
                        lObj.text(alldaty[parseInt(sD)].txt);
                        sObj.parent("td").data("date", SY + "-" + (SM + 1) + "-" + (sD + 1));
                    };

                };
                sObj.parent("td").removeClass("isToday");
                if (cld[sD].isToday) {
                    sObj.parent("td").addClass("isToday");
                    sObj.next("span").text("今天");
                    sObj.parent().removeClass("active"); //设置今天不可点击 
                }; //今日颜色    
            } else { //非日期
                sObj.text("");
                lObj.text("");
                sObj.parent("td").removeClass(icon);
            }
            if (SM == tM) {
                sObj.parents("table").eq(0).find("td.active").eq(0).addClass("recommendday");
            }
        }
        var $ptext = $(".tablediv tbody tr:last td:first p:first");
        if ($ptext.text()) {
            $ptext.parents("tr").css("display", "table-row");
        } else {
            $ptext.parents("tr").css("display", "none");
        }
    }
    //用自定义变量保存当前系统中的年月日
    var Today = new Date();
    var tY = Today.getFullYear();
    var tM = Today.getMonth();
    var tD = Today.getDate();
    //设置的时间
    var setYear = tY;
    var setMonth = tM;
    //打开页时,在下拉列表中显示当前年月,并调用自定义函数drawCld(),显示公历和农历的相关信息
    var alldaty = []; //保存所以天数数据
    var nowdat = [];
    var xxr;
    var tqts;
    if (json) {
        // json.returnDay.sort(function (a, b) {
        //     var time1 = new Date(a);
        //     var time2 = new Date(b);
        //     return time1 - time2;
        // });

        if (typeof json !== "string") {} else { json = JSON.parse(json); };
        nowdat = json.data;
        xxr = json.xxr;
        tqts = json.tqts;
    }

    function initial(y, m) {
        var datalength = solarDays(y, m);
        var noday = 0; //保存没有日期下一天位置
        var sDObj = new Date(y, m, 1); //当月第一天
        var firstWeek = sDObj.getDay(); //公历当月1日星期几
        alldaty = []; //清空当月数据

        for (var i = 0; i < datalength; i++) {
            var nowday = new Date(y, m, i + 1); //当天时间;
            var nowWeek = nowday.getDay(); //公历当月当日星期几
            var obj = {};
            obj.TJRQ = i;
            var isdelday = true;
            var str = [];
            var m01 = m + 1;
            var d01 = i + 1;
            str.push(y, m.toString().length < 2 && m !== 9 ? "0" + m01 : m01, d01.toString().length < 2 ? "0" + d01 : d01);
            var str01 = str.join("-");
            var k;
            for (var z = 0; z < nowdat.length; z++) {
                if (nowdat[z].date == str01) {
                    // var deleteday = (new Date(nowdat[noday].date.replace(/-/g, "/")));
                    k = z;
                    isdelday = false //如果是0，为删除天
                }
            }
            if (!isdelday) {
                //obj.count="不可约";
                obj.count = "";
                obj.txt = nowdat[k].text;
                obj.dataflag = nowdat[k].flag;
                obj.flag = false;
                noday++;
            } else {

                obj.count = "可约";
                obj.flag = true;
            };
            alldaty.push(obj);
        };
        $(".controldiv p").html(y + "<span>年</span>" + (m + 1) + "<span>月</span>");
        var prev = {};
        var next = {};
        if (setMonth == 0) {
            prev.year = setYear - 1;
            prev.month = 11;
            next.year = setYear;
            next.month = setMonth + 1;

        } else if (setMonth == 11) {
            prev.year = setYear;
            prev.month = setMonth - 1;
            next.year = setYear + 1;
            next.month = 0;
        } else {
            prev.year = setYear;
            prev.month = setMonth - 1;
            next.year = setYear;
            next.month = setMonth + 1;
        }
        $(".controldiv a.left").data("year", prev.year).data("month", prev.month);
        $(".controldiv a.right").data("year", next.year).data("month", next.month);
        drawCld(y, m);
    };
    setYear = showyear;
    setMonth = showmonth;
    initial(setYear, setMonth); //初始化日历控件
};

var showtable = function(elemment) {
    var gNum;
    var trarr = [];
    var trstr = "";
    for (var i = 0; i < 7; i++) {
        trstr = '<tr align="center">';
        for (var j = 0; j < 7; j++) {
            gNum = i * 7 + j;
            trstr += '<td id="GD' + gNum + '"><p id="SD' + gNum + '"></p><span id="LD' + gNum + '"></span></td>';
        }
        trstr += '</tr>';
        trarr.push(trstr);
    }
    elemment.append(trarr.join(""));
    $(elemment).find("tr:odd").addClass("color01");
}

showtable($(".tablediv tbody"));

/*加减按钮 在页面里定义*/
// $(".controldiv").on("click", "a.left,a.right", function () {
//     var $this = $(this);
//     var getyear = $this.data("year");
//     var germonth = $this.data("month");

//     $.ajax({
//              url: "calenderjson.json",
//              async:"true",
//              dataType:"json",
//              type:"get",
//              success: function(data){
//              showdate(data, getyear, germonth);
//              $("")

//                },
//                error:function(){
//             alert("flase")
//                }
//     }); 

// });

//一开始先加载渲染日历 在页面里定义
// stratshowdate=function(){
// $.ajax({
//          url: "calenderjson.json",
//          async:"true",
//          dataType:"json",
//          type:"get",
//          success: function(data){
// showdate(data, new Date().getFullYear(), new Date().getMonth());

//            },
//            error:function(){
// alert("flase")
//            }
//   });
// };
// stratshowdate();
// calender插件 end==============================================================





//kk_dropdown插件
//btn_box
//drop_box
//wrap_box
//close_silbings
//body_close
kk_dropdown = function(a) {
    var args = $.extend({}, a);
    var btn = $(args.btn_box),
        drop_box = $(args.drop_box),
        wrap_box = $(args.wrap_box),
        body_close = args.body_close,
        close_silbings = args.close_silbings;
    // wrap_box.click(function(event){event.stopPropagation()});
    close_silbings == undefined ? close_silbings = true : "";
    body_close == undefined ? body_close = true : "";
    wrap_box.on("click", args.btn_box, function() {
        var active = true;
        if (!$(this).parents(args.wrap_box).hasClass("dropdown_active")) { active = false; } //record the status of traget dropbox
        !close_silbings ? "" : $(args.wrap_box).find(args.drop_box).hide().addClass("hide");
        wrap_box.removeClass("dropdown_active"); //int hide all the other dopbox include the target dropbox 
        if (active) {
            wrap_box.find(args.drop_box).show().removeClass("hide");
            wrap_box.addClass("dropdown_active");
        } //reserve the recorded traget dropbox status
        wrap_box = $(this).parents(args.wrap_box);
        if (wrap_box.hasClass("dropdown_active")) {
            wrap_box.find(args.drop_box).hide().addClass("hide");
            wrap_box.removeClass("dropdown_active");
        } else {
            wrap_box.find(args.drop_box).show().removeClass("hide");
            wrap_box.addClass("dropdown_active");
        }
    });

    $("body").on("click", function(e) {
        if (!body_close) {
            return
        }
        var on = false;
        for (var i = 0; i < btn.length; i++) {
            if (e.target == btn[i] || $(e.target).parent()[0] == btn[i]) { on = true }
        };

        if (on) {
            return
        } else {
            wrap_box.find(args.drop_box).hide().addClass("hide");
            wrap_box.removeClass("dropdown_active");
        }
    });
}



//首页焦点图
var bannerslide = function(t) {
    function i(t) {
        this.settings = $.extend({
                targetEle: null,
                callback: function() {}
            }, t),
            this.speed = 700,
            this.autoSpeed = 4000,
            this.$targetEle = $(this.settings.targetEle),
            this.$itemList = this.$targetEle.find('.ps-item'),
            this.$itemBgList = this.$targetEle.find('.ps-bg-item'),
            this.$triggerList = this.$targetEle.find('.ps-trigger-wrap li'),
            this.animateLock = !1,
            this.autoTimer = null,
            this.currentIndex = 0;
        this.init()
    }
    i.prototype.init = function() {
            this.initStyle(),
                this.bindEvent()
        },
        i.prototype.bindEvent = function() {
            var t = this;
            this.timer = null,
                this.$targetEle.find('li').hover(function() {
                    var e = $(this),
                        i = e.index();
                    t.timer = setTimeout(function() {
                        t.switchTo(i)
                    }, 240)
                }, function() {
                    clearInterval(t.timer)
                }),
                this.$targetEle.find('.item-puzzle').on({
                    mouseenter: function() {
                        clearInterval(t.autoTimer)
                    },
                    mouseleave: function() {
                        t.autoPlay()
                    }
                }),
                this.$targetEle.find('.ps-trigger').on({
                    mouseenter: function() {
                        clearInterval(t.autoTimer)
                    }
                })
        },
        i.prototype.getCurrentIndex = function() {
            var t = this.$targetEle.find('.ps-trigger-wrap li.current').index();
            return t
        },
        i.prototype.initStyle = function() {
            this.$itemBgList.eq(0).css({
                    'z-index': '1',
                    opacity: '1'
                }).siblings().css({
                    'z-index': '0',
                    opacity: '0'
                }),
                this.$itemList.eq(0).css({
                    'z-index': '5'
                }).siblings().css({
                    'z-index': '4'
                })
        },
        i.prototype.switchTo = function(t) {
            var e = this,
                i = this.$itemList.eq(t),
                s = this.$itemBgList.eq(t);
            this.animateLock = !0,
                this.$triggerList.eq(t).addClass('current').siblings().removeClass('current'),
                s.siblings().css({
                    'z-index': '0'
                }),
                s.css({
                    zIndex: '1'
                }).stop(!0).animate({
                    opacity: '1'
                }, this.speed, 'linear', function() {
                    $(this).siblings().css({
                        opacity: '0'
                    })
                }),
                i.siblings().css({
                    'z-index': '4'
                }),
                i.css({
                    zIndex: '5'
                }).find('.puzzle-item.item-1 .puzzle-item-block').stop(!0).animate({
                    'margin-left': '0px'
                }, 300, 'swing', function() {
                    e.resetOtherFrames(e.getCurrentIndex())
                }),
                setTimeout(function() {
                    e.animateLock = !1
                }, this.speed / 2)
        },
        i.prototype.resetOtherFrames = function(t) {
            var e = this.$itemList.eq(t);
            e.siblings().each(function() {
                $(this).css({
                        'z-index': '4'
                    }).removeClass('current').removeClass('init'),
                    $(this).find('.puzzle-item').find('.puzzle-item-block').removeAttr('style')
            })
        },
        i.prototype.resetFrame = function(t) {
            var e = this.$itemList.eq(t);
            e.css({
                    'z-index': '4'
                }).removeClass('current').removeClass('init'),
                e.find('.puzzle-item').find('.puzzle-item-block').removeAttr('style')
        },
        i.prototype.autoPlay = function() {
            var t = this,
                e = this.$itemList.length;
            clearInterval(t.autoTimer),
                this.autoTimer = setInterval(function() {
                    var i = t.getCurrentIndex(),
                        s = i === e - 1 ? 0 : i + 1;
                    t.switchTo(s)
                }, t.autoSpeed)
        };
    a = new i(t);
};
// 焦点图end


// ===================show_sub==================  ======================
// show_sub({
// btn: "#index .section05 .con_link_type li",
// subbox: "#index .section05 .link_body",
// event_type: "mouseover",
// wrapbox:"",
// wrap_btn_box:"",
// callback:""
// });
show_sub = function(_args) {
        var args = $.extend({}, _args);
        var btn = $(args.btn),
            subbox = $(args.subbox),
            callback = args.callback,
            wrapbox = $(args.wrapbox),
            wrap_btn_box = $(args.wrap_btn_box),
            allow_reset = args.allow_reset;
        if (wrapbox.length == 0) { wrapbox = $("body") };
        wrapbox.on("click", args.btn, function() {
            var a = $(this).hasClass("active");
            if (!allow_reset) { allow_reset = false } //defulet ban reset
            $(args.btn).removeClass("active");
            !args.wrap_btn_box ? "" : wrap_btn_box.removeClass("active");
            if (allow_reset) {
                if (!a) {
                    $(this).addClass("active");
                    !args.wrap_btn_box ? "" : $(this).parents(args.wrap_btn_box).addClass("active");
                } else {
                    $(this).removeClass("active");
                }
            } else {
                $(this).addClass("active");
                !args.wrap_btn_box ? "" : $(this).parents(args.wrap_btn_box).addClass("active");
            };
            subbox.hide();

            if (allow_reset) {
                if (!a) {
                    var index = $(this).index();
                    subbox.eq(index).show(); // show the consistent contend box which have the same index in ele anrry
                    if (callback) {
                        eval(callback);
                    }
                }
            } else {
                var index = $(this).index();
                subbox.eq(index).show(); // show the consistent contend box which have the same index in ele anrry
                if (callback) {
                    eval(callback);
                }
            }

        })
    }
    // ===================show_sub=============end===========================


// ========================fade_in_out===========if a box wrap a innerbox ,and innerbox want to fadein and fadeout=====
// fade_in_out({
//     btn:"#index .section08 .right li",
//     subbox:"div",
//     btn_include_box:true
// });
fade_in_out = function(_args) {
        var args = $.extend({}, _args);
        var btn = $(args.btn),
            subbox = $(args.subbox),
            wrapbox = $(args.wrapbox),
            include = args.btn_include_box;
        if (wrapbox.length == 0) { wrapbox = $("body") };
        wrapbox.on("mouseenter", args.btn, function() {
            if (include) { $(this).find(args.subbox).fadeIn(200).show(0); } else {
                $(this).parents(args.wrapbox).find(args.subbox).fadeIn(200);
            };
        });
        wrapbox.on("mouseleave", args.btn, function() {
            if (include) { $(this).find(args.subbox).fadeOut(200); } else {
                $(this).parents(args.wrapbox).find(args.subbox).fadeOut(200);
            };
        });
        if (include) { //if the subbox cover the btn, keep it showed
            wrapbox.on("mouseenter", (args.btn + " " + args.subbox), function() {
                $(this).fadeIn(200)
            });
        }
    }
    // ========================fade_in_out================end


// ========================select_data_set====================
// select_data_set({
//     btn: "ul li",
//     target: "div.btn span",
//     wrap_box: "#index .section02 .left_select .li"
// })
select_data_set = function(_args) {
        var args = $.extend({}, _args);
        var btn = $(args.btn),
            target = $(args.target),
            wrapbox = $(args.wrap_box);
        wrapbox.on("click", args.btn, function() {
            if (wrapbox.length == 0) { wrapbox = $("body") };
            if ($(this).parents(args.wrap_box).eq(0).find(args.target)[0].tagName.toLowerCase() == ("input" || "textarea")) {
                $(this).parents(args.wrap_box).eq(0).find(args.target).val($(this).text());
            } else {
                $(this).parents(args.wrap_box).eq(0).find(args.target).text($(this).text());
            }
        });
    }
    // ========================select_data_set====================end




//============scroll listener========================
// scroll_listen({
//     btn_list: "#index .fix_element .left li",
//     anchor: ".scroll_listen"
// });

scroll_listen = function(_args) {
    var args = $.extend({}, _args);
    var navitem = $(args.btn_list),
        section = $(args.anchor);
    var active = "active";
    var scrollspeed = 300;
    var a = "aaaa";
    var b = "bbbb";
    var activeto = function(h, k) {
        navitem.each(function() { $(this).removeClass(active) });
        navitem.eq(k).addClass(active);
    }
    var scrollto = function(h, k) {
        $('html,body').animate({ scrollTop: h }, scrollspeed)
        activeto(h, k)
    }
    for (var i = 0; i < navitem.length; i++) {
        section.eq(i).attr("id", b + (i + 1));
        navitem.eq(i).attr("id", a + (i + 1));
        (function() {
            var k = i;
            var window_height = $(window).height()
            $("#" + a + (k + 1)).click(function() {
                var h = $("#" + b + (k + 1)).offset().top;
                scrollto(h, k);
            });
            $(window).scroll(function() {
                var h = $("#" + b + (k + 1)).offset().top;
                var l = $(window).scrollTop();
                var m = eval(h - l);
                if (m < 200) { //every section box's height must over 200px;
                    activeto(h, k)
                }
            })
        })(i, b)
    }
};
//============scroll listener================end========



//======== overflow_estimate=================================

// overflow_estimate({
//     content:"#product_introduce .section02 .p03 .txt p",
//     wrap_box:"#product_introduce .section02 .p03 .txt li",
//     callback:"add_omit($(this).parents(args.wrap_box).eq(0))"
// });
overflow_estimate = function(a) {
        var args = $.extend({}, a);
        var content = $(args.content),
            wrap_box = $(args.wrap_box);
        content.each(function() {
            var scrollheight = $(this).parents(args.wrapbox)[0].scrollHeight;
            var height = $(this).parents(args.wrap_box).eq(0).height();
            if (scrollheight > height) {
                $(this).parents(args.wrap_box).eq(0).addClass("overflow");
                eval(args.callback);
            }
        })
    }
    //======== overflow_estimate===============end==================




//=================== sub_slide======================
// sub_slide({
//     btn:"#product_introduce .section02 .p03 .title",
//     wrapbox:"#product_introduce .section02 .p03",
//     subbox:".txt",
//     callback:"sub_txt(wrapbox)"
// });
sub_slide = function(a) {
        var args = $.extend({}, a);
        var btn = $(args.btn),
            subbox = $(args.subbox),
            wrapbox = $(args.wrapbox),
            callback = args.callback;
        btn.on("click", btn, function(event) {
            var wrapbox = $(event.target).parents(args.wrapbox).eq(0);
            var subbox = $(event.target).parents(args.wrapbox).eq(0).find(args.subbox);
            $(event.target).parents(args.wrapbox).eq(0).toggleClass("active");
            subbox.slideToggle(200);
            if (callback) {
                eval(callback);
            }
        })
    }
    //=================== sub_slide=================end=====



//==============================kk_dropdown插件=============================
//btn_box
//drop_box
//wrap_box
//close_silbings
//body_close
kk_dropdown = function(a) {
    var args = $.extend({}, a);
    var btn = $(args.btn_box),
        drop_box = $(args.drop_box),
        wrap_box = $(args.wrap_box),
        body_close = args.body_close,
        close_silbings = args.close_silbing,
        change_drop_box = args.change_drop_box,
        callback = args.callback;
    // wrap_box.click(function(event){event.stopPropagation()});
    close_silbings == undefined ? close_silbings = true : "";
    body_close == undefined ? body_close = true : "";
    change_drop_box == undefined ? change_drop_box = true : "";
    wrap_box.on("click", args.btn_box, function() {
        var active = true;
        if (!$(this).parents(args.wrap_box).hasClass("dropdown_active")) { active = false; } //record the status of traget dropbox
        !change_drop_box ? "" : !close_silbings ? "" : $(args.wrap_box).find(args.drop_box).hide().addClass("hide");
        wrap_box.removeClass("dropdown_active"); //int hide all the other dopbox include the target dropbox 
        if (active) {
            !change_drop_box ? "" : wrap_box.find(args.drop_box).show().removeClass("hide");
            wrap_box.addClass("dropdown_active");
        } //reserve the recorded traget dropbox status
        wrap_box = $(this).parents(args.wrap_box);
        if (wrap_box.hasClass("dropdown_active")) {
            !change_drop_box ? "" : wrap_box.find(args.drop_box).hide().addClass("hide");
            wrap_box.removeClass("dropdown_active");
            if (callback) {
                eval(callback);
            }
        } else {
            !change_drop_box ? "" : wrap_box.find(args.drop_box).show().removeClass("hide");
            wrap_box.addClass("dropdown_active");
            if (callback) {
                eval(callback);
            }
        }
    });

    $("body").on("click", function(e) {
        if (!body_close) {
            return
        }
        var on = false;
        for (var i = 0; i < btn.length; i++) {
            if (e.target == btn[i] || $(e.target).parent()[0] == btn[i]) { on = true }
        };

        if (on) {
            return
        } else {
            !change_drop_box ? "" : wrap_box.find(args.drop_box).hide().addClass("hide");
            wrap_box.removeClass("dropdown_active");
        }
    });
};
//==============================kk_dropdown插件===================end==========



//=====================文字动画  给框加data-num值==============
$(function() {
    function numchange() {
        var num = $(".banner_r_box .unslider_banner .li01 .num");
        var a = ["2,000,021", "2,001,154", "2,001,263", "2,001,389", "2,001,458", "2,021,699"];
        var t = num.data("num");
        for (var i = 0; i < (a.length + 1); i++) {
            var yyy = function(i) {
                setTimeout(function() {
                    if (i == a.length) {
                        num.text(t);
                        return;
                    };
                    num.text(a[i])
                }, 90 * (i + 1))
            }(i);
        };
    };
    numchange();
});
//==================文字动画  给框加data-num值==================end




// timecountdown========================
// timecountdown({
//   day01:".day01",
//   day02:".day02",
//   hour01:".hour01",
//   hour02:".hour02",
//   minute01:".minute01",
//   minute02:".minute02",
//   second01:".second01",
//   second02:".second02",
//   endtime:"2017-5-28 1:04:0 GTM+8"
// });

function timecountdown(_arg){
  arg=$.extend({},_arg);
  var day=arg.day,hour=arg.hour,minute=arg.minute,second=arg.second,endtime=arg.endtime,callback=arg.callback,
  day01=arg.day01,hour01=arg.hour01,minute01=arg.minute01,second01=arg.second01,
  day02=arg.day02,hour02=arg.hour02,minute02=arg.minute02,second02=arg.second02;
  var timezone=endtime.match(/GTM.*$/g)[0].replace(/GTM/g,"");
  // check and repair the format
  var split01=endtime.split("-");
  split01[1]=Number(split01[1])>9?split01[1]:split01[1].length>1?split01[1]:"0"+split01[1];
  split01[2]=split01[2].match(/\d{1,2}\s/)[0].replace(/\s/g,"");
  split01[2]=Number(split01[2])>9?split01[2]:split01[2].length>1?split01[2]:"0"+split01[2];
  var split02=endtime.split(":");
  split02[0]=split02[0].match(/\s\d{1,2}/)[0].replace(/\s/g,"");
  split02[0]=Number(split02[0])>9?split02[0]:split02[0].length>1?split02[0]:"0"+split02[0];
  split02[1]=Number(split02[1])>9?split02[1]:split02[1].length>1?split02[1]:"0"+split02[1];
  split02[2]=split02[2].match(/\d{1,2}\s/)[0].replace(/\s/g,"");
  split02[2]=Number(split02[2])>9?split02[2]:split02[2].length>1?split02[2]:"0"+split02[2];
  var split03=endtime.match(/GTM.*$/g)[0];
  endtime=split01.join("-")+" "+split02.join("-")+" "+split03;

  endtime=new Date(Number(endtime.substr(0,4)),Number(endtime.substr(5,2))-1,Number(endtime.substr(8,2)),Number(endtime.substr(11,2)),Number(endtime.substr(14,2)),Number(endtime.substr(17,2))).getTime()-eval(0+timezone)*3600000;//get the utc timesamp of endtime
  function f(){
  var thistime=new Date();
  var thistime=thistime.getTime()+thistime.getTimezoneOffset()*60000;//get the utc timesamp
  subtime=endtime-thistime;//get the time distance
  if(subtime<0){
    eval(callback);return;
  };
  var _day=Math.floor(subtime/1000/60/60/24);
  var _hour=Math.floor(subtime/1000/60/60);
  var _minute=Math.floor(subtime/1000/60-_hour*60);
  var _second=Math.floor(subtime/1000-_hour*60*60-_minute*60);
  _hour=_hour-_day*24;
  _hour=_hour>9?_hour:"0"+String(_hour);
  _minute=_minute>9?_minute:"0"+String(_minute);
  _second=_second>9?_second:"0"+String(_second);
  _day=_day>9?_day:"0"+String(_day);
  $(day).text(_day);
  $(day01).text(String(_day).slice(0,1));
  $(day02).text(String(_day).slice(1));
  $(hour).text(_hour>9?_hour:"0"+_hour);
  $(hour01).text(String(_hour).slice(0,1));
  $(hour02).text(String(_hour).slice(1,2));
  $(minute).text(_minute>9?_minute:"0"+_minute);
  $(minute01).text(String(_minute).slice(0,1));
  $(minute02).text(String(_minute).slice(1,2));
  $(second).text(_second>9?_second:"0"+_second);
  $(second01).text(String(_second).slice(0,1));
  $(second02).text(String(_second).slice(1,2));

  setTimeout(f,1000);
  };
  setTimeout(f,1000);
}

// ====================timecountdown====================end====



//===========跑马灯=======================================
// paomadeng({
//   li:"#index .txt02 .p01 .p001 ul li",
//   ul:"#index .txt02 .p01 .p001 ul",
//   box01:"#demo1",
//   box02:"#demo2",
//   outbox:"#index .txt02 .p01 div.p001 > div",
//   mouseevent:false
// });
//===========跑马灯=======================================
// paomadeng({
//   li:"#index .txt02 .p01 .p001 ul li",
//   ul:"#index .txt02 .p01 .p001 ul",
//   box01:"#demo1",
//   box02:"#demo2",
//   outbox:"#index .txt02 .p01 div.p001 > div",
//   mouseevent:false
// });
function paomadeng(_arg) {
    var arg = $.extend({}, _arg);
    var li = $(arg.li),
        ul = $(arg.ul),
        box01 = $(arg.box01),
        box02 = $(arg.box02),
        outbox = $(arg.outbox),
        mouseevent = arg.mouseenter;
    var allwidth = 2;
    $.each(li, function(i, item) {
        allwidth = allwidth + $(item).outerWidth();
    })
    ul.width(allwidth);
    box02.html(box01.html());
    var onoff = true;
    var outwidth = outbox.innerWidth();
    outbox.width(allwidth*2+3)
    function f() {
        if (!onoff) {
            return };
        var a = box01.css("marginLeft").replace(/px/g, "");
        if (a == (0 - allwidth)) { a = 1; };
        box01.css("marginLeft", Number(a) - 1);
        setTimeout(f, 20);
    };
    setTimeout(f, 20);
    if (mouseevent) {
        outbox.mouseenter(function() {
            onoff = false;
        });
        outbox.mouseleave(function() {
            onoff = true;
            setTimeout(f, 20);
        })
    }
};
//===========跑马灯=============================end==========
//===========跑马灯=============================end==========



// list_intervel_execute({
//     list: "#menu .s04 .li a",
//     callback: "menu_animate(obj)",
//     intervel:100
// })
function list_intervel_execute(_arg) {
    var args = $.extend({}, _arg);
    var list = $(args.list),
        intervel=args.intervel,
        callback = args.callback;

    for(i=0;i<list.length;i++){

    (function(list,intervel,i){
    setTimeout(function(){
            list_intervel_execute(list.eq(i));
    }, intervel*i);

    })(list,intervel,i);
    }

    function list_intervel_execute(obj) {
        if (callback) {
            eval(callback);
        }
    };
};

